#include<bits/stdc++.h>

using namespace std;

int main() {
    vector<int> v = {1, 2, 3, 4};
    do{
        for_each(v.begin(), v.end(), [](int x) -> void {
            cout << x << " ";
        });
        cout << endl;
    }while(next_permutation(v.begin(),v.end()));

}